package com.lry.basic.algorithm.common;

/**
 * @author:刘仁有
 * @desc:
 * @email:953506233@qq.com
 * @data:2019/11/29
 */
public class PeakElement {
    public static void main(String[] args) {
        System.out.println(new PeakElement().findPeakElement(new int[]{1, 2, 1, 3, 5, 6, 4}));
    }
    private int findPeakElement(int[] nums){
        if(null==nums||nums.length==0)return 0;
        int low = 0;
        int high = nums.length-1;
        while(low<high){
            int mid = (low+high)/2;
            if(nums[mid]>nums[mid+1]){
                high = mid;
            }else{
                low = mid+1;
            }
        }
        return low;
    }
}
